package org.code.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author xiaojian
 * <p>
 * 日期工具类
 */
public class DateUtil {

    public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    /**
     * 获取当前时间戳
     *
     * @return 当前时间戳
     */
    public static long getCurrentTime() {
        return System.currentTimeMillis();
    }

    public static String getNowTime(String format) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
        return formatter.format(getNow());
    }

    public static String getNowTime() {
        return getNowTime(DATE_FORMAT);
    }

    public static LocalDateTime getNow() {
        return LocalDateTime.now();
    }

    public static void main(String[] args) {
        System.out.println(getNowTime());
        System.out.println(getNow());
    }


}
